//
//  GWStatusePhotoView.m
//  新浪微博
//
//  Created by qianfeng on 16/2/19.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWStatusePhotoView.h"
#import "UIImageView+WebCache.h"
#import "GWStatuseModel.h"

@interface GWStatusePhotoView ()
@property (nonatomic,weak)UIImageView *gifView;
@end
@implementation GWStatusePhotoView
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self =[super initWithFrame:frame]) {
        self.contentMode =UIViewContentModeScaleAspectFill;
        self.clipsToBounds= YES;
        self.userInteractionEnabled =YES;
        
        UIImage *image =[UIImage imageNamed:@"timeline_image_gif"];
        UIImageView *gifView =[[UIImageView alloc]initWithImage:image];
        [self addSubview:gifView];
        self.gifView =gifView;
    }
    return self;
}
-(void)setPhotoModel:(GWPhotoModel *)photoModel
{
    _photoModel =photoModel;
    [self sd_setImageWithURL:[NSURL URLWithString:photoModel.thumbnail_pic] placeholderImage:[UIImage imageNamed:@"timeline_image_placeholder"]];
    
    NSString *extension =photoModel.thumbnail_pic.pathExtension.lowercaseString;
     self.gifView.hidden =![extension isEqualToString:@"gif"];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.gifView.x =self.width-self.gifView.width;
    self.gifView.y =self.height-self.gifView.height;
}

@end
